package 共享锁;

import java.util.ArrayList;

public class CountDownLatchDemo {
    public static void main(String[] args) throws InterruptedException {
        ArrayList arrayList = new ArrayList();
        for (int i = 0; i < 10; i++) {
            final int j = i;
            Thread t = new Thread(new Runnable() {
                @Override
                public void run() {
                    System.out.println(j);
                }
            });
            arrayList.add(t);
        }
        for (int i = 0; i < arrayList.size(); i++) {
            Thread t = (Thread) arrayList.get(i);
            t.start();
            t.join();
        }
        //我们希望在这里等待以上10个线程执行完毕之后，再去做其他事情
        System.out.println("main");
    }
}
